Contrôle du mouvement des axes simples
Voir le PLCopenSingle.project
exemple de projet dans le répertoire d'installation de CODESYS en dessous de ..\CODESYS SoftMotion\Examples
.
Cet exemple montre comment piloter un entraînement à l'aide de blocs fonction standardisés PLCopen.
Insérez un lecteur virtuel nommé
Drive
dans l'arborescence des appareils ci-dessous Pool d'axes généraux SoftMotion.Créer un MOTION_PRG programme à ST.
PROGRAM MOTION_PRG VAR iStatus: INT; Power: MC_Power; MoveAbsolute: MC_MoveAbsolute; p:REAL:=100; END_VAR CASE iStatus OF // initialization of the axis 0: Power(Enable:=TRUE, bRegulatorOn:=TRUE, bDriveStart:=TRUE, Axis:=Drive); IF Power.Status THEN iStatus := iStatus + 1; END_IF // Move the axis to position p by use of the MC_MoveAbsolute function block 1: MoveAbsolute(Execute:=TRUE, Position:= p, Velocity:=100, Acceleration:=100, Deceleration:=100, Axis:=Drive); IF MoveAbsolute.Done THEN MoveAbsolute(Execute:=FALSE, Axis:=Drive); iStatus := iStatus + 1; END_IF // Move the axis back to position 0 by use of the MC_MoveAbsolute function block: 2: MoveAbsolute(Execute:=TRUE, Position:= 0, Velocity:=100, Acceleration:=100, Deceleration:=100, Axis:=Drive); IF MoveAbsolute.Done THEN MoveAbsolute(Execute:=FALSE, Axis:=Drive); iStatus := 1; END_IF
Ajouter l'appel du programme MOTION_PRG à la tâche Tâche principale.
Arborescence des appareils :
Téléchargez le projet dans le contrôleur et démarrez-le.
Ouvrez le Conduire axe virtuel dans l'éditeur.
Dans le En ligne partie de la Général onglet, vous voyez le mouvement de l'axe.